#ifndef _AV_TRANSCODER_STREAM_OUTPUT_STREAM_HPP_
#define _AV_TRANSCODER_STREAM_OUTPUT_STREAM_HPP_

#include "IOutputStream.hpp"

struct AVStream;

namespace avtranscoder
{

class OutputFile;

class AvExport OutputStream : public IOutputStream
{
public:
    OutputStream(OutputFile& outputFile, const size_t streamIndex);

    size_t getStreamIndex() const { return _streamIndex; }
    float getStreamDuration() const;
    size_t getNbFrames() const; ///< If audio stream, returns number of packets
    int getStreamPTS() const;   ///< Get current AVStream PTS

    bool isPTSGenerated() const { return _isPTSGenerated; }
    IOutputStream::EWrappingStatus wrap(const CodedData& data);

private:
    OutputFile& _outputFile;         ///< Has link (no ownership)
    const AVStream& _outputAVStream; ///< Has link (no ownership)

    size_t _streamIndex; ///<  Index of the stream in the output file

    //@{
    // @brief These attributes will help us to get the stream duration.
    // @see ffmpeg hack: https://github.com/FFmpeg/FFmpeg/blob/master/libavformat/mux.c#L585
    // @see getStreamDuration
    size_t _wrappedPacketsDuration; //< the addition of the duration of all packets wrapped by this stream.
    int _lastWrappedPacketDuration; //< The duration of the last packet wrapped by this stream.
    bool _isPTSGenerated;           //< Is the PTS generated by ffmpeg/libav (in case of generator for example)
                                    //@}
};
}

#endif
